Skip to content

Zigbee Switch: Fix Climax power meter scaling - #3205

Open
sungmpar wants to merge 3 commits into
SmartThingsCommunity:mainfrom
sungmpar:fix/climax-power-scaling
Open

Zigbee Switch: Fix Climax power meter scaling#3205
sungmpar wants to merge 3 commits into
SmartThingsCommunity:mainfrom
sungmpar:fix/climax-power-scaling

Conversation

@sungmpar

Copy link
Copy Markdown

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Summary

  • Add an exact Climax-specific nested power-meter subdriver.
  • Delegate Electrical Measurement ActivePower to the SDK-standard handler.
  • Delegate Simple Metering InstantaneousDemand to the SDK-standard handler.
  • Add regression tests covering multiplier, divisor, and kW-to-W conversion.

Root cause

The shared zigbee-switch-power compatibility handlers divide reported values by the configured divisor but do not apply the corresponding multiplier. The shared InstantaneousDemand path also emits a kW-scaled value as watts without multiplying by 1000.

Changing these shared handlers globally could alter established compatibility behavior for other fingerprinted devices.

Implementation

The nested subdriver matches only manufacturer ClimaxTechnology and model PSM_00.00.00.35TC. It overrides only Electrical Measurement ActivePower and Simple Metering InstantaneousDemand, delegating both attributes to the existing SDK-standard handlers.

The shared compatibility handlers and all non-Climax device behavior remain unchanged.

Hardware validation

No SmartThings hub or physical Climax device was used. Automated integration tests verify driver and subdriver routing, multiplier/divisor field use, numerical scaling, kW-to-W conversion, and emitted powerMeter events.

The physical-device test plan is to pair a PSM_00.00.00.35TC with a SmartThings hub and verify report ordering, endpoint behavior, and emitted watt values against a known load when hardware is available. That hardware validation was not performed for this change, so firmware report ordering, endpoint quirks, and deployed-device behavior remain unverified.

Fixes #236

Summary of Completed Tests

  • test_switch_power: 7/7 passed
  • test_aurora_relay: 4/4 passed
  • test_ledvance_metering_plug: 4/4 passed
  • Complete Zigbee-switch suite: 63 files, 575/575 tests passed
  • Luacheck: 0 warnings and 0 errors in the four changed files
  • Whitespace checks passed

@CLAassistant

CLAassistant commented Aug 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sungmpar

Copy link
Copy Markdown
Author

Hi @cjswedes, I hope you're doing well.

Whenever you have a chance, would you or someone on the team be able to take a look at this PR?

I noticed that the Run driver tests, Luacheck, and Upload driver packages workflows are still awaiting maintainer approval.

The change is intentionally scoped to ClimaxTechnology / PSM_00.00.00.35TC so that the existing shared compatibility behavior for other devices remains unchanged. It addresses #236 by routing ActivePower and InstantaneousDemand through the SDK-standard handlers, with regression tests covering the scaling behavior.

If a different approach would be preferable, or if any additional validation is needed, I would be very happy to make any necessary changes.

Thank you very much for your time and for reviewing contributions to the project.

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

zigbee-switch_coverage.xml

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/init.lua 86%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/stateless_handlers/init.lua 44%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/zigbee-dimming-light/osram-iqbr30/init.lua 77%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/ge-link-bulb/init.lua 81%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/firstled-io/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/zigbee-dimming-light/zll-dimmer/init.lua 81%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/tuya-multi/can_handle.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/laisiao/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/preferences.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/ikea-xy-color-bulb/init.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm32-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/configurations/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient-IO/unbind_request.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient-IO/init.lua 88%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/color_temp_range_handlers/init.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/zll-polling/init.lua 81%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm30-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/rgbw-bulb/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/white-color-temp-bulb/init.lua 82%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/white-color-temp-bulb/duragreen/init.lua 66%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 184101a

@github-actions

Copy link
Copy Markdown

Test Results

   73 files    541 suites   0s ⏱️
3 267 tests 2 823 ✅ 0 💤 0 ❌ 444 🔥
5 256 runs  4 668 ✅ 0 💤 0 ❌ 588 🔥

For more details on these errors, see this check.

Results for commit 184101a.

@cjswedes

Copy link
Copy Markdown
Contributor

Thank you for putting up this change to address this issue, I think there is a simpler way to address the issue rather than adding another nested subdriver.

First, some context. The zigbee-switch-power subdriver itself is a bit useless IMO. Basically all these subdrivers do is set divisor/multipliers to be used in the ActivePower and InstantaneousDemand report handlers. It then proceeds to override those handlers with ones that do not consider the multiplier, as you have mentioned. I am not sure if changing those handlers will cause an issue with other devices. The subdriver exists because when we switched from groovy DTHs to Lua edge drivers, we tried to do a 1 to 1 port of functionality; likely the defaults are sufficient for all these devices, like the ClimaxTechnology device you are fixing.

Since the fix here is to use the defaults, rather than adding nested subdriver which then overrides the already overridden defaults with the defaults again, we should just have this device stop using the zigbee-switch-power subdriver entirely. Remove it from the fingerprints.lua file and then your tests pass. You then do not need the nested subdriver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClimaxTechnology Power Meter | power unit divisor

3 participants